﻿Imports BUS
Imports DTO
Public Class frmGiaoDienBoPhan : Inherits DevComponents.DotNetBar.Office2007Form

    Private Sub frmGiaoDienBoPhan_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Reload()
    End Sub

    Private Sub Reload()
        Dim lquyentheobophan As List(Of CQuyenTheoBoPhanDTO) = New CQuyenTheoBoPhanBUS().LoadQuyenTheoBoPhan()
        Dim stt = 0
        DataGridViewXQuyenBoPhan.Rows.Clear()
        For Each item As CQuyenTheoBoPhanDTO In lquyentheobophan
            stt += 1
            DataGridViewXQuyenBoPhan.Rows.Add(stt, item.Ma, New CBoPhanBUS().LayTenBoPhanTheoMa(item.MaBoPhan), item.RibbonBarTheThuVien, item.RibbonBarQuanLySach, item.RibbonBarThuTienPhat, item.RibbonBarMuonTraSach, item.RibbonBarTimKiemTheoSach, item.RibbonBarTimKiemTheoDocGia, item.RibbonButtonBaoCaoMuonTheoTheLoai, item.RibbonButtonBaoCaoSachTraTre, item.RibbonButtonBaoCaoDocGiaNoTienPhat)
        Next
    End Sub

    Private Sub ButtonXCapNhat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonXCapNhat.Click
        Dim dto As CQuyenTheoBoPhanDTO
        Dim kt As Boolean
        For Each item As DataGridViewRow In DataGridViewXQuyenBoPhan.Rows
            dto = New CQuyenTheoBoPhanDTO()
            dto.Ma = item.Cells("clMa").Value
            dto.RibbonBarTheThuVien = item.Cells("clTheThuVien").Value
            dto.RibbonBarQuanLySach = item.Cells("clQuanLySach").Value
            dto.RibbonBarThuTienPhat = item.Cells("clThuTienPhat").Value
            dto.RibbonBarMuonTraSach = item.Cells("clMuonTraSach").Value
            dto.RibbonBarTimKiemTheoSach = item.Cells("clTimKiemTheoSach").Value
            dto.RibbonBarTimKiemTheoDocGia = item.Cells("clTimKiemTheoDocGia").Value
            dto.RibbonButtonBaoCaoMuonTheoTheLoai = item.Cells("clBaoCaoMuonTheoTheLoai").Value
            dto.RibbonButtonBaoCaoDocGiaNoTienPhat = item.Cells("clBaoCaoDocGiaNoTienPhat").Value
            dto.RibbonButtonBaoCaoSachTraTre = item.Cells("clBaoCaoSachTraTre").Value
            kt = New CQuyenTheoBoPhanBUS().UpdateQuyenTheoBoPhan(dto)
        Next
        Reload()
    End Sub
End Class